package thinkingJava.chapter11;

import java.util.ArrayList;

public class ApplesAndOrangesWithoutGeneric {

	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static void main(String[] args) {
		ArrayList apples = new ArrayList();
		for (int i = 0; i < 3; i++) {
			apples.add(new Apple());
		}
		apples.add(new Orange());

		for (int i = 0; i < apples.size(); i++) {
			System.out.println(((Apple)apples.get(i)).id());
		}
	}
//	public static void main(String[] args) {
//		ArrayList<Apple> apples = new ArrayList<Apple>();
//		for (int i = 0; i < 3; i ++) {
//			apples.add(new Apple());
//		}
//		for (int i = 0; i < apples.size(); i++) {
//			System.out.println(apples.get(i).id());
//		}
//		for (Apple ap : apples) {
//			System.out.println(ap.id());
//		}
//	}
}
class Apple {
	private static  long counter;
	private final long id = counter++;
	public long id() {
		return id;
	}
}
class Orange {

}